<?php
/**
 * Description of ValidateInValue
 *
 * @author Damiano Ciarla
 */
class ValidateInValue implements Validate
{
    public function validate($field, $value, $condition = null)
	{
		if(!is_null($value))
		{
			if(!in_array($value, $condition))
			{
				$listVal = "(";

				foreach ($condition as $val)
				{
					$listVal .= "'" . $val . "'";

					if(!(end($condition) == $val))
						$listVal .= ", ";
				}

				$listVal .= ")";

				return T::_("Il campo") . " <b><u>" . ucfirst($field) . "</u></b> " . T::_("deve avere uno dei seguenti valori") . " " . $listVal;
			}
		}

		return true;
	}
}
?>
